list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


def list_while_func():
    global list2
    list2 = []
    index = 0
    while index < len(list1):
        if list1[index] % 2 == 0:
            list2.append(list1[index])
        index += 1


list_while_func()
print(f"通过while循环，从列表{list1}中取出偶数，组成的新列表：{list2}")


def list_for_func():
    global list2
    list2 = []
    index = 0
    for element in list1:
        if element % 2 == 0:
            list2.append(element)
        index += 1

list_for_func()
print(f"通过for循环，从列表{list1}中取出偶数，组成的新列表：{list2}")


